import {
  Column,
  CreateDateColumn,
  Entity,
  JoinColumn,
  ManyToOne,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';
import { InstrumentCategory } from './instrument-category.entity';

@Entity()
export class Instrument {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string;

  @Column({ nullable: true })
  cover: string;

  @Column()
  location: string;

  @Column({ nullable: true })
  manager_id: number;

  @ManyToOne(() => InstrumentCategory)
  @JoinColumn({ name: 'category_id' })
  category: InstrumentCategory;

  @Column()
  manufacturer: string;

  @Column()
  manu_at: string;

  @Column({ type: 'bigint', comment: '出厂时间戳（秒）' })
  manu_date: number;

  @Column()
  manu_no: string;

  @Column({ nullable: true })
  ref_no: string;

  @Column({ type: 'bigint', comment: '采购时间戳（秒）' })
  purchased_date: number;

  @Column({ nullable: true })
  specification: string;

  @Column({ nullable: true })
  features: string;

  @Column({
    type: 'int',
    default: 1,
    comment: '状态(1:可使用 2:维修中 3:禁用)',
  })
  status: number;

  @CreateDateColumn()
  created_at: Date;

  @UpdateDateColumn()
  updated_at: Date;
}
